package operator.function.do_;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import util.Printer;
import util.RxJavaHelper;

class DoOnSubscribeOperator {

    public static void main(String[] args) {
        doOnSubscribe();
    }

    static void doOnSubscribe() {
        Observable.just("test")
                .doOnSubscribe(new Consumer<Disposable>() {
                    @Override
                    public void accept(Disposable disposable) throws Exception {
                        Printer.print("doOnSubscribe disposable = " + disposable);
                    }
                })
                .subscribe(new Observer<String>() {
                    @Override
                    public void onSubscribe(Disposable disposable) {
                        Printer.print("doOnSubscribe onSubscribe disposable = " + disposable);
                    }

                    @Override
                    public void onNext(String String) {
                        Printer.print("doOnSubscribe onNext String = " + String);
                    }

                    @Override
                    public void onError(Throwable throwable) {

                    }

                    @Override
                    public void onComplete() {
                        Printer.print("doOnSubscribe onComplete");
                    }
                });
    }


}
